﻿using System;
using System.Collections.Generic;
using System.Text;
using TSVNAddin.TSVN;
using EnvDTE;
using EnvDTE80;

namespace TSVNAddin.Core
{
	public class GenericPathCommand : ICommand
	{
		private readonly TortoiseProcExecutor _TortoiseProcExecutor;
		private readonly Repository _Repository;
		private TortoiseProcCommandType _TortoiseCommandType;
		private TortoiseProcArgumentType[] _TortoiseArguments;

		public GenericPathCommand(TortoiseProcExecutor tortoiseProcExecutor, Repository repository, TortoiseProcCommandType tortoiseCommandType, params TortoiseProcArgumentType[] tortoiseArguments)
		{
			_TortoiseProcExecutor = tortoiseProcExecutor;
			_Repository = repository;
			_TortoiseCommandType = tortoiseCommandType;
			_TortoiseArguments = tortoiseArguments;
		}

		public void Execute()
		{
			string rootPath = _Repository.GetWorkingRoot();
			_TortoiseProcExecutor.Exec(_TortoiseCommandType, rootPath, _TortoiseArguments);
		}

		public CommandStatus QueryStatus()
		{
			if (!_Repository.IsActive())
				return CommandStatus.VisibleAndDisabled;

			return CommandStatus.VisibleAndEnabled;
		}
	}
}
